package com.example.black.myapplication.androidframwork;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.ListView;

/**
 * <pre>
 *     author : 28476
 *     e-mail : hao.wang@1hai.cn
 *     time   : 2018/11/05/16:58
 *     desc   :
 *     version: 1.0
 * </pre>
 */

public class MyListView extends ListView {

    public static final String TAG = "MyListView";

    public MyListView(Context context) {
        super(context);
    }

    public MyListView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyListView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
         super.dispatchTouchEvent(ev);
        String action = "no action";
        switch (ev.getAction())
        {
            case MotionEvent.ACTION_DOWN:
                action = "down";
                break;
            case MotionEvent.ACTION_MOVE:
                action = "move";
                break;
            case MotionEvent.ACTION_UP:
                action = "up";
                break;
        }
        Log.e(TAG, "MyListView dispatchTouchEvent: "+ ev.getAction()+"desc "+action);
         return true;
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        Log.e(TAG, "onTouchEvent: "+ev.getAction());
        String action = "no action";
        switch (ev.getAction())
        {
            case MotionEvent.ACTION_DOWN:
                action = "down";
                break;
            case MotionEvent.ACTION_MOVE:
                action = "move";
                break;
            case MotionEvent.ACTION_UP:
                action = "up";
                break;
        }
      //  requestDisallowInterceptTouchEvent(true);
        Log.e(TAG, "MyListView onTouchEvent: "+ ev.getAction()+"desc "+action);
        super.onTouchEvent(ev);
        return true;
    }
}
